
var initIFrameStyle = function(initWidth,initHeight) {
	var mainFrame = parent.$("#mainFrame");
	var mainWidth = mainFrame.width() - initWidth;
	var mainHeight = mainFrame.height() - initHeight;
	$("#viewFrame").width(mainWidth);
	$("#treeFrame,#viewFrame").height(mainHeight);
};

var loadTableScroll = function(){
	var winHeight = initWinHeight(37);
	if(winHeight>0){
		$("#scrollTable").height(winHeight);
		$("#scrollTable").css({"overflow-y":"auto","overflow-x": "hidden"});
	}
};

var initWinHeight = function(initHeight) {
	var mainFrame = top.$("#mainFrame");
	var viewFrame = mainFrame.contents().find("#viewFrame");
	var winHeight = 0;
	if (viewFrame.attr("id") == undefined) {
		winHeight = mainFrame.height() - initHeight;
	} else {
		winHeight = viewFrame.height() - initHeight;
	}
	return winHeight;
};

var loadLocalPath = function(url) {
	var mainFrame = top.$("#mainFrame");
	var viewFrame = mainFrame.contents().find("#viewFrame");
	if (viewFrame.attr("id") == undefined) {
		mainFrame.contents().empty();
		mainFrame.removeAttr("src");
		mainFrame.attr("src", url);
	} else {
		viewFrame.contents().empty();
		viewFrame.removeAttr("src");
		viewFrame.attr("src", url);
	}
};

var updatePwd = function() {
	var basePath = $("#basePath").val();
	ymPrompt.win({
		title : "您当前窗口：修改密码",
		fixPosition : true,
		maxBtn : false,
		minBtn : false,
		width : 550,
		height : 280,
		winPos : "c",
		message : basePath+"/pwd.do",
		iframe : true
	});
};

$.fn.serializeObject = function() {
	var o = {};
	var a = this.serializeArray();
	$.each(a, function() {
		if (o[this.name]) {
			if (!o[this.name].push) {
				o[this.name] = [ o[this.name] ];
			}
			o[this.name].push(this.value || '');
		} else {
			o[this.name] = this.value || '';
		}
	});
	return o;
};

var wechatMsgType = {"text":"文本消息","news":"图文消息","image":"图片消息","voice":"语音消息","video":"视频消息","music":"音乐消息"};
var wechatMenuType = {"click":"消息触发","view":"网页链接","pic_sysphoto":"微信拍照发图","scancode_waitmsg":"微信扫码"};var wechatMenuType = {"click":"消息触发类","view":"网页链接类","pic_sysphoto":"微信拍照发图","scancode_waitmsg":"微信扫码"};
/**
 * 计算时间间隙，直观展示时间间隔
 * @param timestamp 时间戳
 * @returns {*}
 * from wxl
 */
var  getTimeGap = function(timestamp)   {
	var YEAR = 365 * 24 * 60 * 60;// 年
	var MONTH = 30 * 24 * 60 * 60;// 月
	var DAY = 24 * 60 * 60;// 天
	var HOUR = 60 * 60;// 小时
	var MINUTE = 60;// 分钟
	var nowTime = new Date().getTime();

	var timeGap = (nowTime - timestamp) / 1000;// 与现在时间相差秒数
	var timeStr = null;
	if (timeGap > YEAR) {
		timeStr = parseInt(timeGap / YEAR) + "年前";
	} else if (timeGap > MONTH) {
		timeStr = parseInt(timeGap / MONTH) + "个月前";
	} else if (timeGap > DAY) {// 1天以上
		timeStr = parseInt(timeGap / DAY) + "天前";
	} else if (timeGap > HOUR) {// 1小时-24小时
		timeStr = parseInt(timeGap / HOUR) + "小时前";
	} else if (timeGap > MINUTE) {// 1分钟-59分钟
		timeStr = parseInt(timeGap / MINUTE) + "分钟前";
	} else {// 1秒钟-59秒钟
		timeStr = "刚刚";
	}
	return timeStr;

}
/**
 * 格式化标准日期（long型转换），条件表达式主要作用是加0，使视图显示整齐
 * @param timestamp 时间戳
 * @returns {string} 时间显示字符串
 * from wxl
 */
function   formatDate(timestamp)   {
	var time = new Date(parseInt(timestamp));
	var   year=time.getFullYear();
	var   month=time.getMonth()+1;
	month=month<10?'0'+month:""+month;
	var   date=time.getDate();
	date=date<10?'0'+date:""+date;
	var   hour=time.getHours();
	hour=hour<10?'0'+hour:""+hour;
	var   minute=time.getMinutes();
	minute=minute<10?'0'+minute:""+minute;
	var   second=time.getSeconds();
	second=second<10?'0'+second:""+second;
	return   year+"-"+month+"-"+date+"   "+hour+":"+minute+":"+second;
}